﻿Imports Microsoft.VisualBasic
Imports System.Data
Public Class NotificacionesEmail

    Public lErrorG As Boolean
    Dim Msg As String
    Shared ReadOnly Property _MailAdmin() As String
        Get
            Return ConfigurationManager.AppSettings("MailAdmin").ToString
        End Get
    End Property
    Public Function Correo_Cumpleaños() As String
        Dim p As New Egresados
        Dim dt As DataTable = p.GetCumplimentados()
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim Body As String = Cargar_Plantilla(dt, "CUMPLEAÑOS")
            Body = Body.Replace("{NOMBRE}", dt.Rows(i)("Nombre").ToString)
            Body = Body.Replace("{FECHA}", Format(Today, "dd MMMM yyyy"))
            Dim Asunto As String = String.Format("FELIZ CUMPLEAÑOS TE DESEA LA FUNDACIÓN UNIVERSITARIA SAN MARTÍN")
            Dim CC As String = dt.Rows(i)("EMail").ToString
            Msg = Mail.EnviarNot(dt.Rows(i)("EMail").ToString, Asunto, Body, CC) + "<BR/> Envio " + Now.ToString
        Next
        Return Msg
    End Function
    Public Function Correo_Evaluacion(ByVal Id_Ofer_Est As String, ByVal tip_eval As String, ByVal dt As DataTable, ByVal plantilla As String) As String
        Dim Body As String = plantilla
        Body = Body.Replace("{FECHA_ACTUAL}", Format(Today, "dd 'de' MMMM 'de' yyyy"))
        Body = Body.Replace("{JEFE_RELACORP}", "SINDY PAOLA LOPEZ")
        Body = Body.Replace("{ENTIDAD}", "UPARSYSTEM")
        Body = Body.Replace("{NOM_ESTUDIANTE}", dt.Rows(0)("Nombre").ToString)
        Body = Body.Replace("{IDENTIFICACION}", dt.Rows(0)("Id_Estudiante").ToString)
        Body = Body.Replace("{NOM_EMPRESA}", dt.Rows(0)("NOM_EMPRESA").ToString)
        Body = Body.Replace("{FECHA_EXAMEN}", dt.Rows(0)("Fecha").ToString)
        Body = Body.Replace("{TIP_EVAL}", dt.Rows(0)("TIP_EVAL").ToString)
        Body = Body.Replace("{NOM_REP_LEGAL}", dt.Rows(0)("Rep_Legal").ToString)
        Dim Asunto As String = String.Format("NOTIFICACIÓN DE EVALUACIÓN DE DESEMPEÑO")
        Dim CC As String = ""
        Msg = Mail.EnviarNot(_MailAdmin, Asunto, Body, CC) + "<BR/> Envio " + Now.ToString
        Return Msg
    End Function
    Public Function Cargar_Plantilla(ByVal datos As DataTable, ByVal Nomb_Plantilla As String) As String
        Dim obj As CorreosE = New CorreosE
        Dim dtc As DataTable = obj.GetPorNomb(Nomb_Plantilla)
        Dim m As String = ""
        If dtc.Rows.Count > 0 Then
            m = dtc.Rows(0)("Cuerpo").ToString
        End If
        Return m
    End Function

End Class
